package com.roc.web.action.merinfo;

import java.util.ArrayList;
import java.util.List;

import com.roc.page.BaseSearchCondition;
import com.roc.page.WhereHQLFieldBean;
import com.roc.util.Constance;

public class MerinfoRejectedSearchCondition extends BaseSearchCondition{
	private String startingDate;//起始日期
	private String endDate;//结束日期
	private String merinfoNo;//商户号
	private String merinfoName;//商户名
	
	@Override
	protected List<WhereHQLFieldBean> getWhereHQLFieldBeanList() {

		List<WhereHQLFieldBean> filedBeanList = new ArrayList<WhereHQLFieldBean>();
		
		//商户号
		if (Constance.isNotEmpty(merinfoNo)) {
			filedBeanList.add(new WhereHQLFieldBean("a.obj_audited", merinfoNo.trim(), "=", false));
		}
		
		
		if(Constance.isNotEmpty(startingDate)){
         	filedBeanList.add(new WhereHQLFieldBean("to_char(a.dt_create, 'yyyyMMdd')",startingDate.trim(),">=", false));
       	}
		
		
		if(Constance.isNotEmpty(endDate)){
         	filedBeanList.add(new WhereHQLFieldBean("to_char(a.dt_create, 'yyyyMMdd')",endDate.trim(),"<=", false));
       	}
		
		if (Constance.isNotEmpty(merinfoName)) {
			filedBeanList.add(new WhereHQLFieldBean("e.name", merinfoName.trim(),"LIKE", false, "ALL"));
		}
		
		return filedBeanList;
	}
	@Override
	protected String getRowCountHQL() {

		return "select count(*) "
				+ "from t_auditing_item a left join tbl_edit_mcht_inf e on a.obj_audited = e.mcht_cd "
					                   + "left join t_operators p on e.ext1 = to_char(p.id) "
					                   + "left join t_operators o on a.operators = o.account_no "
				+ "where a.audit_code='3003' and a.result_code='02'";
	}
	@Override
	protected String getSearchHQL() {

		return "select to_char(a.dt_create, 'yyyyMMdd'),a.obj_audited,e.mcht_cd,e.bank_belong_cd,"
				+ "p.real_name ,e.name,e.name_busi,e.contact_name,e.contact_phoneno,o.real_name auditorName,a.result_detail,"
				+ "(select ta.name from tbl_area ta where ta.id = p.companyid) branchcompy,"
				+ "(select s1.real_name from t_operators s1  where s1.role_type = '02' and s1.oneagentid = p.oneagentid) oneagent "
				+ "from t_auditing_item a left join tbl_edit_mcht_inf e on a.obj_audited = e.mcht_cd "
				+ "left join t_operators p on e.ext1 = to_char(p.id) "
				+ "left join t_operators o on a.operators = o.account_no "
				+ "where a.audit_code='3003' and a.result_code='02'";
	}
	@Override
	protected String getOrderPartOfHQL() {
		
		return "order by to_char(a.dt_create, 'yyyyMMdd') desc";
	}
	public String getStartingDate() {
		return startingDate;
	}
	public void setStartingDate(String startingDate) {
		this.startingDate = startingDate;
	}
	public String getEndDate() {
		return endDate;
	}
	public void setEndDate(String endDate) {
		this.endDate = endDate;
	}
	public String getMerinfoNo() {
		return merinfoNo;
	}
	public void setMerinfoNo(String merinfoNo) {
		this.merinfoNo = merinfoNo;
	}
	public String getMerinfoName() {
		return merinfoName;
	}
	public void setMerinfoName(String merinfoName) {
		this.merinfoName = merinfoName;
	}
	
	
}
